Skip to content

feat(inference-api): first-class OpenResponses with front-door state - #281

Open
michaelneale wants to merge 3 commits into
mainfrom
gandalf/openresponses
Open

michaelneale wants to merge 3 commits into
mainfrom
gandalf/openresponses

Conversation

@michaelneale

Copy link
Copy Markdown
Contributor

Original problem

Skippy's /v1/responses is a stateless translation onto Chat Completions. It has no previous_response_id, no /v1/responses/compact, no WebSocket transport, and no strict structured output. Standalone skippy serve passes 1/17 of the official OpenResponses compliance kit.

Mesh-LLM/mesh-llm#3105 built a full implementation, but inside a Mesh-only crate (mesh-openresponses). That copied private Skippy helpers and left two Responses protocol layers. The agreed direction is one implementation in Skippy that Mesh consumes, as it already does for the OpenAI handling. #3105 will be closed in favour of this PR plus a Mesh pin bump.

Fix

This ports #3105's Responses code, which originally lived in skippy/crates/, onto skippy main.

skippy-inference-api::responses now covers:

  • typed resources, the lifecycle and SSE events
  • previous_response_id continuation over a bounded, caller-scoped ResponseStore
  • /v1/responses/compact
  • the Responses WebSocket transport, through a reusable ResponsesSession
  • stream replay and obfuscation

skippy-serving brings back strict json_schema structured output (frontend/request/structured_output).

Architecture

Conversation state lives only at the front door a client connects to.

  • InferenceFrontendConfig::default() is now stateless. Embedded backends started with start_openai_backend* never store or resolve turns: they report store: false and every previous_response_id is not found. That is the path Mesh providers use, so a provider can never hold state for traffic another ingress prepared.
  • Standalone skippy serve (instrumented_openai_router) opts in with with_configured_response_storage(). SKIPPY_RESPONSE_STORAGE=off disables it.
  • A host with its own ingress, such as Mesh, keeps its own ResponseStore there. It sends expanded, stateless turns to its backends.

Hardening on top of #3105:

  • Via, CF-Connecting-IP and True-Client-IP now join Forwarded, X-Forwarded-For and X-Real-IP as proxy headers. Any of them denies the host-local caller scope.
  • A Responses WebSocket upgrade carrying a browser Origin that is neither loopback nor the same as Host gets 403.

Not included: #3105's tool-emulation rework. Main's tool emulation has since been rewritten (recurrent checkpoint prefixes), and the two conflict. If it's still needed, it will be a separate PR.

Compatibility

  • Behaviour change for embedders: InferenceFrontendConfig::default() no longer creates a store. Hosts that want continuation must call with_response_store or with_configured_response_storage.
  • New public API: InferenceFrontendConfig::with_configured_response_storage and responses::RESPONSE_STORAGE_ENV (SKIPPY_RESPONSE_STORAGE). The responses::* session, store and stream types are now public.
  • New dependency: chacha20poly1305, which seals compaction items. The key is process-local.
  • No ABI or llama.cpp changes.

Validation

All runs were at 754ef54 on an M5 Max.

  • cargo fmt --all --check: ok.
  • cargo clippy --workspace --all-targets --no-default-features -- -D warnings: ok.
  • cargo test --workspace --no-default-features --no-fail-fast: 5064 passed, 0 failed.
  • just embedding-contract-check: fmt, check --locked and clippy pass. 5 skippy-serving embedded::tests fail locally with "set SKIPPY_NATIVE_RUNTIME_BUNDLE_DIR". They need a native runtime bundle, and CI provides one.
  • just build, then skippy serve --model-path Qwen2.5-VL-3B-Instruct-Q4_K_M.gguf --mmproj mmproj-…-Q8_0.gguf (Metal):
    • Official compliance kit (openresponses/openresponses dce9ddb, bin/compliance-test.ts): 17/17. Before this change standalone was 1/17.
    • Live checks:
      • HTTP continuation recalled a code word from turn 1.
      • Continuing with X-Forwarded-For: \xff, Via or CF-Connecting-IP returned 404.
      • WebSocket Origin: http://evil.example returned 403; http://localhost:3000 returned 101.
      • Strict json_schema returned 3/3 schema-valid objects.
      • With SKIPPY_RESPONSE_STORAGE=off: store: false, and continuation returned 404.
    • With text-only Qwen2.5-3B, Image Input fails as expected ("multimodal request requires a configured projector"), giving 16/17.
  • Model or hardware qualification beyond this Metal smoke test has not run.

Acceptance criteria

  • I ran the relevant local checks, or explained why they do not apply.
  • I agree to license my contributions under the Apache License, Version 2.0.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 42419c91-f5aa-42a0-ba7c-fb1728bcf591
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Skippy Lab Qualification: Passed

Commit: ed148cacfb0c702e3fbcf0f5c5e94140859424e7 · PR smoke · Workflow and timings · Saved evidence

Native Spark lab qualification.

Latest successful main: run 46152803372, attempt 1, commit b22fd13ad71717ac42001899de1354b355960291. Comparison unavailable: workload inputs changed or could not be verified.

Configuration Outcome Prefill tok/s Prefill vs main Decode tok/s Decode vs main Actions logs
qwen35-4b-standalone Passed 3622.7 Unavailable 63.8 Unavailable Logs
qwen3-coder-30b-a3b-standalone Passed 2872.0 Unavailable 85.7 Unavailable Logs
qwen3-coder-30b-a3b-split Passed 2109.5 Unavailable 55.9 Unavailable Logs
qwen36-35b-a3b-standalone Passed 1946.6 Unavailable 65.6 Unavailable Logs
qwen36-35b-a3b-split Passed 1853.6 Unavailable 39.3 Unavailable Logs
qwen38-flash-next-standalone Passed 728.8 Unavailable 29.1 Unavailable Logs
qwen38-flash-next-split Passed 530.8 Unavailable 26.1 Unavailable Logs

TPS comes from three separate warmed, uncached probes at concurrency 1, each generating exactly 128 tokens. The scored correctness answers and each probe's 64-token warmup are excluded. Each rate is total tokens / total server-reported phase time, not an average of request rates. Client elapsed times and raw responses are retained in throughput-probe.json. These bounded samples are not sustained benchmarks or controlled speedup comparisons. Legacy short-answer receipts and missing or invalid probe evidence show as Unavailable.

Deltas use unrounded rates from matching PR-profile smoke receipts on the latest successful main run, including the nightly smoke evidence. Positive means faster. Changed workload inputs, different serving host classes, unequal phase token counts or missing evidence show Unavailable. Physical Spark placement and runtime conditions can differ; deltas are descriptive, not controlled speedup claims.

Smoke checks cover GPU startup, deterministic endpoint repeats and bounded streaming. They do not establish an AgentX performance score. Nightly history and saved performance baselines are published separately; a saved baseline can be older than the latest successful main run used here. Native build and qualification output streams into each configuration’s Actions log, with per-attempt copies in Saved evidence. Any capture gaps are reported in the log and saved diagnostics. GitHub evidence copies expire after 30 days.

@i386 i386 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified at head 754ef54c7048bac65400cfa3aae4c06f8b71ab1f (single squashed commit, 51 files, +13,635/−913). Content verified end to end; no blocking findings. I am not approving — the owner's manual read gates approval, and the branch conflicts with main.

Front-door state split — the load-bearing claim verifies. InferenceFrontendConfig::default() carries response_store: None; embedded backends (embedded.rs builds config from default() plus an optional lifecycle observer only) are stateless and every previous_response_id 404s. Standalone serving opts in via with_configured_response_storage() in instrumented_openai_router. Pinned by default_frontend_is_stateless_for_backends_behind_another_front_door.

Env switch fails closed — SKIPPY_RESPONSE_STORAGE accepts only the explicit on/off words; empty is unset, and any unrecognized value turns storage off with a warning.

Caller scope — caller_scope_for_http_peer grants LocalHost only to a direct loopback peer (IPv4-mapped IPv6 handled) with no forwarding header present; all six headers (forwarded, x-forwarded-for, x-real-ip, via, cf-connecting-ip, true-client-ip) deny on presence alone, value-independent. Store lookups are scope-keyed, so proxied or unknown peers cannot read or write local state; tests pin denial on both read and write.

WebSocket — reject_cross_origin_upgrade runs before the upgrade: a browser Origin must equal Host (case-insensitive) or resolve to localhost/loopback; non-http(s) schemes and authorities containing / or @ are refused; cross-origin gets 403 before any session state exists. Absent Origin (non-browser client) is allowed, which is standard.

Compaction — sealed with ChaCha20Poly1305 under a process-local OS-CSPRNG key; nonce-prefixed sealed payloads; summary size bounded.

Store bounded — 30-minute TTL, 128 responses and 64 MiB per caller, 256 callers and 256 MiB global; branches share parent chains in memory but are charged the full transcript at admission.

Other — retention controls (store/background) validated pre-dispatch with the backend provably never called on invalid input; strict json_schema enforces grammar⊕schema mutual exclusion, object shape, and a non-empty name through the bounded native parser. The tool-emulation rework is genuinely absent as described — only responses/tools.rs and the max-tool-call limit tests are touched; serving-layer emulation files are untouched.

Evidence — the body's validation run cites 754ef54, which is the head. CI at head is green: 8/8 qualification lanes (including qwen36), Same-repository CI, and both commit-status gates; skipped lanes are the path-profile routing, not failures. This resolves my objections to #3105 — the evidence is at head and real lanes ran.

Gates before merge: (1) conflicts with main across Cargo.lock, the inference-api lib/responses/router files, guardrails tests and serving files — rebase required, and main's rewritten tool emulation (recurrent checkpoint prefixes) is the semantic overlap to recheck on rebase; (2) the documented embedder behavior change means the mesh consumer must pin and verify when #3105 closes in favor of this; (3) owner approval per standing policy.

Port the OpenResponses implementation from Mesh-LLM/mesh-llm#3105 into
skippy-inference-api so standalone Skippy and embedding hosts share one
implementation:

- typed Responses resources, lifecycle and SSE events
- previous_response_id continuation with a bounded, caller-scoped store
- /v1/responses/compact and the Responses WebSocket transport
- strict json_schema structured output in skippy-serving

Conversation state lives only at the front door a client connects to.
InferenceFrontendConfig::default() is now stateless, so embedded backends
started with start_openai_backend* never store or resolve turns. Standalone
`skippy serve` opts in through with_configured_response_storage(), which
SKIPPY_RESPONSE_STORAGE=off disables.

Hardening:
- Via, CF-Connecting-IP and True-Client-IP join the proxy headers that deny
  the host-local caller scope.
- Responses WebSocket upgrades with a cross-origin browser Origin get 403.
@michaelneale
michaelneale force-pushed the gandalf/openresponses branch from 754ef54 to 387b51d Compare December 1, 2026 04:58
i386
i386 previously approved these changes Dec 1, 2026

@i386 i386 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Rebased head verified — approving.

Re-checked at 387b51d (rebased onto 87bee44), local gates green in a clean worktree with the pinned toolchain (cargo/rustc 1.99.1, clippy 0.1.99):

  • cargo fmt -p skippy-api -p skippy-inference-api -p skippy-serving --check → clean
  • cargo check --locked --offline -p skippy-api -p skippy-inference-api -p skippy-serving --features skippy-api/dynamic-native-runtime → exit 0
  • cargo clippy ... --all-targets -- -D warnings → exit 0
  • cargo test --locked --offline -p skippy-api -p skippy-inference-api --features skippy-api/dynamic-native-runtime → exit 0
  • cargo test -p skippy-serving --lib readiness::tests → 4 passed. (embedded::tests needs SKIPPY_NATIVE_RUNTIME_BUNDLE_DIR; 5 native-runtime tests fail here for that reason, 6 non-native pass — environmental, same in any checkout.)

What the rebase had to change, and where I checked it lands correctly:

  • router/generation.rs: the /v1/responses handler stays relocated to router/responses.rs; the old copy is gone, so main's recurrent-decode edit from #280 has no site left there and #280's content is intact at the head.
  • The relocated handler and responses/execution.rs now go through request_context(&InferenceLifecycleContext, ..) rather than a bare request id, so responses turns inherit the receipts work (#180): the turn's receipt and the host-minted exchange id are published on the backend context, and stream usage observation is set. That is the right direction — the earlier hardcoded construction dropped both.
  • Three test literals (router/max_tool_calls_tests.rs, router/responses_websocket/tests.rs) pick up the new receipt field.

Scope of this approval: source read plus local build/lint/test evidence on macOS. No GPU/model qualification here — that is the pending qualification (qwen36-35b-a3b-split) lane, which auto-merge will wait on.

Follow-through outside this diff: once mesh #3105 closes in favor of this, mesh needs its pin bump, as noted on the earlier review.

@i386
i386 enabled auto-merge December 1, 2026 05:02
…n live models

Lab qualification now posts to /v1/responses on every admitted model:

- a strict json_schema request with a prompt that asks for anything but
  JSON, non-streaming and over SSE; the output must parse and match the
  schema exactly, and the SSE deltas must equal the completed response;
- a two-turn previous_response_id continuation that must recall the
  first turn.

The compliance kit has a single schema fixture, so a 17/17 run did not
show that decoding is enforced. Unconstrained, the same prompt returns a
poem and fails this check.
Mesh's ingress accepts Responses WebSocket upgrades itself and needs the
same browser-origin rule as skippy serve. Export it as
responses::websocket_origin_allowed instead of copying it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants